package com.arrcen.medicen.core.match.exception;

import com.arrcen.medicen.core.match.model.ResultError;
import com.arrcen.medicen.core.match.model.dto.Result;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
    public ResultError MyExceprion(Exception e) {
        ResultError result=new ResultError(e.getLocalizedMessage(),e.getMessage());
        return result;
    }

    @ExceptionHandler(MyException.class)
    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
    public ResultError MyRuntimeExceprion(MyException e) {
        ResultError result=new ResultError(e.error,e.error_description);
        return result;
    }


}